let api = 'http://localhost:3000';
let token = localStorage.getItem('token');
function myAjax({url,type='get',data={},dataType=''}){
    let apiUrl = api + url;
    return new Promise((resolve,reject)=>{
        $.ajax({
            url:apiUrl,
            type,
            data,
            dataType,
            headers:{
                authorization:token
            },
            success(res){
                resolve([null,res]);
            },
            error(err){
                resolve([err,null]);
            }
        })
    })
}

function transQuery(query){
    let obj = {};
    let str = query.slice(1);
    let arr = str.split('&');
    arr.forEach(item=>{
        let arr1 = item.split('=');
        obj[arr1[0]] = decodeURIComponent(arr1[1]);
    })
    return obj;
}